//拖拽
(function (w) {

	w.$={};
	w.$.drag=function(obj,callback){
		var startPoint={x:0,y:0};
		var elementPoint={x:0,y:0};
		obj.onmousedown = function(ev) {
		obj.setCapture && obj.setCapture();
		ev = ev ||event;
		startPoint.x=obj.offsetLeft;
		startPoint.y=obj.offsetTop;
		elementPoint.x=ev.clientX;
		elementPoint.y=ev.clientY;

		document.onmousemove = function(ev) {
			ev = ev ||event;
			var nowPoint={x:0,y:0};
			nowPoint.x=ev.clientX;
			nowPoint.y=ev.clientY;
			var L=startPoint.x+(nowPoint.x-elementPoint.x);
			if(L<0){
				L=0;
			}else if(L>obj.parentNode.clientWidth-obj.offsetWidth){
				L=obj.parentNode.clientWidth-obj.offsetWidth;
			}
			obj.style.left=L+"px";
			if(callback&&callback["move"]&&typeof callback["move"]==="function"){
				callback["move"].call(obj);
			}
		};
		document.onmouseup = function() {
			document.onmousemove =document.onmouseup = null;
			obj.releaseCapture && obj.releaseCapture();
		};
		return false;
		};
	}
})(window);
